#include<iostream>
using namespace std;
#include<iomanip>

double exp1(double x, double trun = 1E-6){

	int n=0;
	double term=1;
	double y=term;
	while( (term *= x/(++n)) > trun ){
		y += term;
	}
	return y;
}

double exp2(double x, double trun = 1E-6){

	int n=0;
	double term=1;
	while( (term *= x/(++n)) > trun ){
	}

	term /= x/(n--);
	double y = term;
	while(n>=1){
		term /= x/(n--);
		y += term;
	}
	return y;
}

int main(){

	cout<<setprecision(15)<<"exp1="<<exp1(1,1E-100)<<endl;
	cout<<"exp2="<<exp2(1,1E-100)<<endl;
	return 0;
}
